"""翻译工具类"""
from translations import translations

class Translator:
    _instance = None
    _current_language = 'zh_CN'  # 默认中文
    
    def __new__(cls):
        if cls._instance is None:
            cls._instance = super().__new__(cls)
        return cls._instance
    
    @classmethod
    def set_language(cls, language):
        """设置当前语言"""
        if language in translations:
            cls._current_language = language
    
    @classmethod
    def get_text(cls, key):
        """获取翻译文本"""
        try:
            return translations[cls._current_language][key]
        except KeyError:
            # 如果找不到翻译，返回键值
            return key
    
    @classmethod
    def get_language(cls):
        """获取当前语言"""
        return cls._current_language 